# Contributor: Peter Shkenev <santurysim@gmail.com>
# Maintainer: Peter Shkenev <santurysim@gmail.com>
pkgname=freediameter
pkgver=1.5.0
_gitcommit="33dbbd20c9107a765dbafb9b1fef16f5f47c65cd"
pkgrel=1
pkgdesc="Free implementation of Diameter protocol"
url="https://github.com/open5gs/freediameter"
arch="all"
options="!check" #no test suite
license="BSD-3-Clause"
makedepends="cmake libgcrypt-dev libidn-dev gnutls-dev flex bison samurai"
subpackages="$pkgname-dev $pkgname-libfdcore $pkgname-libfdproto $pkgname-extensions"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/open5gs/freediameter/archive/$_gitcommit.tar.gz
	"
builddir="$srcdir/freeDiameter-$_gitcommit"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DDISABLE_SCTP=ON \
		$CMAKE_CROSSOPTS
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

libfdcore() {
	pkgdesc="$pkgdesc (core library)"
	amove usr/lib/libfdcore.so.*
}

libfdproto() {
	pkgdesc="$pkgdesc (protocol library)"
	amove usr/lib/libfdproto.so.*
}

extensions() {
	pkgdesc="$pkgdesc (extensions)"
	amove usr/lib/freeDiameter
}

sha512sums="
91a003447bee8174e89b1244f6d89c67c0686193ea6b5e2b0588156ec648d8ff6ee4b16ce6ccf081e2606916c1f1e2a7037e044f3149e10cd180424b669f136c  freediameter-1.5.0.tar.gz
"
